package com.likan.chqjtgc.controller;

import com.likan.chqjtgc.commons.R;
import com.likan.chqjtgc.enums.HttpStatus;
import com.likan.chqjtgc.service.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : liuxinghong
 * @Description : 登录调用相关接口
 * @date: 2020/11/30 18:54
 **/
@Api(tags = {"登出"})
@RestController
@Slf4j
@RequestMapping("/")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @ApiOperation(value = "登出")
    @GetMapping("/logout")
    public R logout(@RequestParam("clientId") String clientId, @RequestParam("userName") String userName){
        try {
            return R.ok(loginService.logout(clientId,userName));
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return R.failed(false, HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }

}
